package com.itheima.webaitliasserver;

import cn.hutool.core.io.FileUtil;
import com.google.gson.Gson;
import com.itheima.webaitliasserver.pojo.Result;
import com.itheima.webaitliasserver.utils.AliyunOssOperator;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.test.context.SpringBootTest;

import java.io.File;

/**
 * @ClassName: xiaoZhang
 * @Description:
 * @Author: Zhang
 * @CreateDate: 2025-09-27 19:56
 */
@Slf4j
@SpringBootTest
public class SpringBootWebBean {
    @Autowired
    private AliyunOssOperator aliyunOssOperator;

    @Autowired
    private Gson gson;
    @Test
    public void testUpload() throws Exception {
        System.out.println("开始上传");
        String path = "D:\\职业生涯学习\\后端\\javaweb\\webAI-Tlias-Server\\src\\main\\resources\\static\\images\\001.jpg";
        File file = new File(path);
        log.info("file = {}", aliyunOssOperator);
        String url = aliyunOssOperator.upload(FileUtil.readBytes(file) , "1.jpg");
        log.info("url:{}" , url);
    }
    @Test
    public void GsonTransform () {
        log.info(gson.toJson(Result.success("成功")));
    }
}
